<?php
class DiaryListCacheModel {
    
	private $redisModel;
	
	function __construct() {
		$this->redisModel    =    new RedisModel();
	}

	public function getHighQualitySubscription($id,$length)
	{
		if (AC::REDIS_READ){
	        return $this->redisModel->getHighQualitySubscription($id,$length);
	    }
	}
	/**
	 * 增加点滴话题缓存
	 * @param unknown $gid
	 * @param unknown $data
	 */
	public function addDiaryTopicHash($id, $data){
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addDiaryTopicHash($id, $data);
	    }
	}
	
	/**
	 * 获取hash
	 * @param unknown $gid
	 * @param unknown $data
	 */
	public function getDiaryTopicHash($id){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getDiaryTopicHash($id);
	    }
	}
	/**
	 * 获取一个官方点滴话题热度
	 * @param unknown $tid
	 * @return unknown
	 */
	public function getDiaryTopicOfficialHot($tid){
	    if (AC::REDIS_READ){
	        return  $this->redisModel->getDiaryTopicOfficialHot($tid);
	    }
	}
	
	/**
	 * 将话题添加官方列表中
	 * @param unknown $id
	 * @return unknown
	 */
	public function addDiaryTopicToOfficialSet ($id, $score) {
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addDiaryTopicToOfficialSet($id, $score);
	    }
	}

	/**
	 * 获取所有热门点滴话题
	 * @return unknown
	 */
	public function getDiaryTopicOfficialByHot(){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getDiaryTopicOfficialByHot();
	    }
	}

    /**
     * 返回热门点滴话题的排序
     * @param $gid
     * @return mixed
     */
    public function getDiaryTopicRank($gid){
        if (AC::REDIS_READ){
            return $this->redisModel->getDiaryTopicRank($gid);
        }
    }

    /**
     * 获取热门点滴话题列表（人为干预的）
     * @param $start
     * @param $length
     * @return mixed
     */
    public function getDiaryTopicCache($start, $length){
        if (AC::REDIS_READ){
            $length = $start + $length - 1;
            return $this->redisModel->getDiaryTopicCache($start, $length);
        }
    }
	
	/**
	 * 获取自动生成的话题热度榜
	 * @param unknown $id
	 * @param unknown $length
	 */
	public  function getDiaryTopicByHot(){
	    if (AC::REDIS_READ){
	        return  $this->redisModel->getDiaryTopicByHot();
	    }
	}
	/**
	 * 获取点滴话题的热度
	 */
	public function getDiaryTopicHot($tid){
	    if (AC::REDIS_READ){
	        return  $this->redisModel->getDiaryTopicHot($tid);
	    }
	}
	/**
	 * 获取点滴话题对应的点滴数
	 * @param unknown $id
	 */
	public function getDiaryTopicCountCache($id){
	    if (AC::REDIS_READ){
	        return  $this->redisModel->getDiaryTopicCountCache($id);
	    }
	}
	/**
	 *  增加城市id
	 */
	public function addCityIdCache($data){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addCityIdCache($data);
	    }
	}
	/**
	 *  获取城市id
	 */
	public function getCityIdCache($hash){
	    if (AC::REDIS_READ){
	     return  $this->redisModel->getCityIdCache($hash);
	    }
	}
	
	/**
	 * 删除GEO缓存
	 */
	public function removeCityCache($key, $value){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->removeCityCache($key, $value);
	    }
	}
	/**
	 * 增加GEO缓存
	 */
	public function addCityCache($key,$value,$time=AC::SERVER_TIME){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addCityCache($key,$value,$time);
	    }
	}
	/**
	 * 
	 * @param unknown $key
	 * @param unknown $typeNum
	 */
	public function getCityCache($key, $id, $length){
	    if (AC::REDIS_READ){
	      return  $this->redisModel->getCityCache($key, $id, $length);
	    }
	}
	
	/**
	 * 将点滴加进列表
	 * @param unknown $key
	 * @param unknown $value
	 * @param unknown $time
	 */
	public function addTopicDiaryToList ($key,$value,$time=AC::SERVER_TIME) {
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addTopicDiaryToList($key,$value,$time);
	    }
	}
	
	/**
	 * 从列表中删除点滴话题
	 * @param unknown $key
	 * @param unknown $value
	 */
	public function removeTopicDiaryOfList($key, $value){
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->removeTopicDiaryOfList($key, $value);
	    }
	}
	
	/**
	 * 获取点滴列表
	 * @param unknown $key
	 * @param unknown $id
	 * @param unknown $length
	 * @return multitype:
	 */
	public function getDiarysByTopicId ($key, $id, $length) {
	    if (AC::REDIS_READ){
	        return  $this->redisModel->getDiarysByTopicId($key, $id, $length);
	    }
	}
	
	/**
	 * 获取广场最新列表,有传分类则显示分类
	 * @param unknown $diaryInfo
	 * @return multitype:unknown
	 */
	public function getSquareNewList($diaryInfo)/*{{{*/
	{
	    $category = intval($diaryInfo ['category']);
	    $category = ($category > 0 && $category < 19) ? $category : 0;
	     
	    $lenth = AC::DIARY_LIST_DEFAULT_LEN;
	    if (! empty ( $diaryInfo ["length"] )) {
	        $lenth = intval ( $diaryInfo ["length"] );
	        if ($lenth < 1 || $lenth > AC::DIARY_LIST_DEFAULT_LEN ) {
	            $lenth = AC::DIARY_LIST_DEFAULT_LEN;
	        }
	    }
	    
	    $bodyId    =    '0';
	    if (intval($diaryInfo['id']) > 0){
	        $bodyId    = intval($diaryInfo['id']);
	    }
	    $result = $this->redisModel->getSquareTimeline($category, $bodyId, '0', $lenth);
	    $bodyList =array();
	    if (!empty($result)){
	        foreach($result as $bodyId){
	            $list['bodyId'] = $bodyId;
	            $bodyList[]  =  $list;
	        }
	    }
	    return $bodyList;
	}
	
	#  group  start    #
	// 添加圈子缓存
	public function addGroupCache($gid, $data){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addGroup($gid, $data);
	    }
	}
	// 添加圈子计数,话题数,成员数，今日新增话题数
	public function addGroupCount($gid, $type, $num=1){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addGroupCount($gid, $type, $num);
	    }
	}
	// 修改圈子缓存单个字段信息
	public function setGroupCount($gid, $type, $value){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setGroupCount($gid, $type, $value);
	    }
	}
	// 修改圈子信息
	public function setGroupCache($gid,$info){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setGroup($gid,$info);
	    }
	}
	// 获取圈子信息
	public function getGroupCache($gid){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getGroup($gid);
	        return $result;
	    }
	}
	// 删除圈子信息
	public function delGroupCache($gid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delGroup($gid);
	    }
	}
	/**
	 * 圈子非数据库字段数据存储、修改
	 * @param unknown $gid
	 * @param unknown $values
	 */
	public function setGroupNodbCache($gid,$values){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setGroupNodbCache($gid,$values);
	    }
	}

    /**
     * 增加圈子用户
     * @param $gid
     * @param $uid
     * @param $time
     */
	public function addGroupUser($gid, $uid, $time = AC::SERVER_TIME){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addGroupUser($gid, $uid, $time);
	    }
	}

	/**
	 * 删除圈子用户
	 * @param unknown $gid
	 * @param unknown $values
	 */
	public function removeGroupUser($gid,$uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->removeGroupUser($gid,$uid);
	    }
	}

    /**
     * 获取圈子用户
     * @param $gid
     * @param int $start
     * @param int $length
     * @return mixed
     */
	public function getGroupUser($gid, $start = 0, $length = -1){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getGroupUser($gid, $start, $length);
	    }
	}

    /**
     * 获取圈子用户个数
     * @param $gid
     * @return mixed
     */
	public function getGroupUserNum($gid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getGroupUserNum($gid);
	    }
	}

	# 官方圈子
	public function addOfficialGroupCache($gid) {
	    if(AC::REDIS_WRITE) {
	        return $this->redisModel->addOfficialGroupCache($gid);
        }
    }
    # 官方圈子
    public function getOfficialGroupCache($start, $len) {
	    if(AC::REDIS_READ) {
	        return $this->redisModel->getOfficialGroupCache($start, $len);
        }
    }
    # 官方圈子
    public function delOfficialGroupCache() {
	    if(AC::REDIS_WRITE) {
	        return $this->redisModel->delOfficialGroupCache();
        }
    }
    # 推荐圈子
    public function addRecommendGroup($gid, $score){
	    if(AC::REDIS_WRITE) {
	        return $this->redisModel->addRecommendGroup($gid, $score);
        }
    }
    # 推荐圈子
    public function getRecommendGroup($start, $len) {
        if(AC::REDIS_READ) {
            return $this->redisModel->getRecommendGroup($start, $len);
        }
    }
    # 推荐圈子
    public function getGroupScore($gid) {
        if(AC::REDIS_READ) {
            return $this->redisModel->getGroupScore($gid);
        }
    }

    public function getTopGroups($category, $start=0, $len=-1) {
        if(AC::REDIS_READ) {
            return $this->redisModel->getTopGroups($category, $start, $len);
        }
    }
    public function getCountGroupListByCategory($category){
        if(AC::REDIS_READ) {
            return $this->redisModel->getCountGroupListByCategory($category);
        }
    }

    public function getGroupRangeByCategory($category, $start, $len){
        if(AC::REDIS_WRITE) {
            return $this->redisModel->getGroupRangeByCategory($category, $start, $len);
        }
    }
    //分类圈子列表倒序
    public function getGroupListByCategory($category, $start, $len){
        if(AC::REDIS_WRITE) {
            return $this->redisModel->getGroupListByCategory($category, $start, $len);
        }
    }
    //分类圈子列表
    public function addGroupListByCategory($category, $score, $gid){
        if(AC::REDIS_READ) {
            return $this->redisModel->addGroupListByCategory($category, $score, $gid);
        }
    }
    public function remGroupByCategory($category, $gid){
        if(AC::REDIS_WRITE) {
            return $this->redisModel->remGroupByCategory($category, $gid);
        }
    }

	/**
	 * 今日话题数自增1
	 * @param unknown $gid
	 * @param unknown $type
	 * @param unknown $num
	 */
	public function groupTodayNumIncrete($gid, $type, $num){
	    if (AC::REDIS_WRITE){
		$this->redisModel->groupTodayNumIncrete($gid, $type, $num);
	    }
	}
	/**
	 * 获取圈子非数据库字段信息
	 * @param unknown $gid
	 */
	public function getGroupNodbCache($gid){
	    if (AC::REDIS_READ){
		return $this->redisModel->getGroupNodbCache($gid);
	    }
	}
	public function addGroupBlackUser($gid, $uid) {
	    if(AC::REDIS_WRITE) {
	        return $this->redisModel->addGroupBlackUser($gid, $uid);
        }
    }
    public function getGroupBlockUser($gid) {
	    if(AC::REDIS_READ) {
	        return $this->redisModel->getGroupBlockUser($gid);
        }
    }
	/**
	 * 圈子中对用户的操作
	 */
	public function addGroupUserCache($uid, $data){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addGroupUserCache($uid, $data);
	    }
	}
	public function getUserGroupAllCache($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getUserGroupAllCache($uid);
	    }
	}

    public function getUserFollowTopicsAllCache($uid){
        if (AC::REDIS_READ){
            return $this->redisModel->getUserFollowTopicList($uid);
        }
    }
    public function addUserFollowTopic($uid, $gid, $sort=AC::SERVER_TIME){
        if (AC::REDIS_READ){
            return $this->redisModel->addUserFollowTopic($uid, $gid, $sort);
        }
    }
    public function delUserFollowTopic($uid, $gid){
        if (AC::REDIS_READ){
            return $this->redisModel->delUserFollowTopic($uid, $gid);
        }
    }
    public function rmUserFollowTopic($uid){
        if (AC::REDIS_READ){
            return $this->redisModel->removeUserFollowTopic($uid);
        }
    }
    /**
	 * 用户浏览的圈子话题
	 */
    public function addUserViewTopicInfo($uid, $tid){
        if (AC::REDIS_WRITE){
            return $this->redisModel->addUserViewTopicInfo($uid, $tid);
        }
    }
    public function getUserViewTopic($uid, $start = 0, $length = 20){
        if (AC::REDIS_READ){
            return $this->redisModel->getUserViewTopic($uid, $start, $length);
        }
    }

    /**
     * 暂停圈子
     * @param $gid
     * @param $time
     * @return mixed
     */
    public function pauseGroup($gid, $time) {
        if (AC::REDIS_WRITE) {
            return $this->redisModel->pauseGroup($gid, $time);
        }
    }

    /**
     * 获取暂停圈子列表
     * @return mixed
     */
    public function getPauseGroupList() {
        if (AC::REDIS_READ) {
            return $this->redisModel->getPauseGroupList();
        }
    }

    /**
     * 删除暂停已过期的圈子
     * @param int $time
     * @return mixed
     */
    public function deletePauseGroup($time = AC::SERVER_TIME) {
        if (AC::REDIS_WRITE) {
            return $this->redisModel->deletePauseGroup($time);
        }
    }
    //封禁时间
    public function getPauseGroupTime($gid){
        if(AC::REDIS_READ) {
            return $this->redisModel->getPauseGroup($gid);
        }
    }

	/**
	 * 话题置顶列表
	 * @param unknown $tid
	 * @param unknown $time
	 */
	public function addTopicList($tid, $time = AC::SERVER_TIME){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addTopicList($tid, $time);
	    }
	}
	// 获取话题置顶列表
	public function getTopicList($start, $lenght=20){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getTopicList($start, $lenght);
	    }
	}
	// 搜索置顶话题
	public function findStickStopicInfo($tid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->findStickTopic($tid);
	    }
	}
	// 删除话题所有信息
	public function delTopicInfo($tid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delTopic($tid);
	    }
	}
	// 添加话题缓存
	public function addTopicCache($tid, $data){
	    if (AC::REDIS_WRITE){
	       isset($data['attachments']) &&  $data['attachments']  =  json_encode($data['attachments']);
	       isset($data['voiceList'])   &&  $data['voiceList']    =  json_encode($data['voiceList']);
	        $this->redisModel->addTopic($tid, $data);
	    }
	}
	// 获取话题缓存
	public function getTopicInfo($tid){
	    if (AC::REDIS_READ){
	       $result = $this->redisModel->getTopic($tid);
	       if (!empty($result['attachments'])){
	           $result['attachments']  =  json_decode($result['attachments'],true);
	           $result['voiceList']    =  json_decode($result['voiceList'],true);
	       }
	       return $result;
	    }
	}
	// 自增话题计数
	public function changeTopicCount($tid, $type, $num = 1){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addTopicCount($tid, $type, $num);
	    }
	}
	// 将话题加入最新时间线
	public function addTopicToSquareTimeline($tid){
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addTopicToSquareTimeline(0, $tid);
	    }
	}
	// 获取话题广场列表
	public function getTopicSquareList($category, $tid, $start, $length)
	{
	    $result = $this->redisModel->getSquareTimelineOfTopic($category, $tid, $start, $length);
	    return $result;
	}
	#  group  end      #
	
	# shop list 通用
	public function getShopListData ($redisKey, $sort, $id, $start, $length) {
	    if (AC::REDIS_READ){
	        return $this->redisModel->getShopListData ($redisKey, $sort, $id, $start, $length);
	    }
	}
	
	public function addShopListData($redisKey, $sort, $id) {
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addShopListData($redisKey, $sort, $id);
	    }
	}

	#  chatgroup  start      #
	// 获取缓存
	public function getMysqlDataHashCache($table, $primaryKey){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getMysqlDataHashCache($table, $primaryKey);
	        return $result;
	    }
	}
	// 设置缓存
	public function setMysqlDataHashCache($table, $primaryKey, $value){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setMysqlDataHashCache($table, $primaryKey, $value);
	    }
	}
	// 删除缓存
	public function delMysqlDataHashCache($table, $primaryKey){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delMysqlDataHashCache($table, $primaryKey);
	    }
	}
	// 修改数字
	public function setCount($table, $primaryKey, $field, $num){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setCount($table, $primaryKey, $field, $num);
	    }
	}

	// 创建用户加入的群组列表
	public function addOneToUserChatGroups($gid, $uid){
		if (AC::REDIS_WRITE){
			$this->redisModel->addOneToUserChatGroups($gid, $uid, AC::SERVER_TIME);
		}
	}

	// 删除用户加入的群组
	public function delOneFromUserChatGroups($gid, $uid){
		if (AC::REDIS_WRITE){
			$this->redisModel->delOneFromUserChatGroups($gid, $uid);
		}
	}

	// 获取用户加入的群组列表
	public function getUserChatGroupList($uid, $start, $end){
		if (AC::REDIS_READ){
			return $this->redisModel->getUserChatGroupList($uid, $start, $end);
		}
	}

	// 加入用户到群中
	public function addUserToChatGroup($uid, $gid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addUserToChatGroup($gid, AC::SERVER_TIME, $uid);
	    }
	}
	// 获取群中的用户列表
	public function getChatGroupUsersList($gid, $start, $end){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getChatGroupUsersCacheList($gid, $start, $end);
	        return $result;
	    }
	}
	// 删除这个群的用户列表
	public function delChatGroupAllUsers($gid){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->delChatGroupAllUsers($gid);
	        return $result;
	    }
	}
	// 踢出群中的用户/用户推出
	public function delChatGroupUser($uid, $gid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delChatGroupUserCache($gid, $uid);
	    }
	}
	// 设置群组聊天缓存
	public function setGroupChatMessageCache($gid, $id, $data){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setGroupChatMessageCache($gid, $id, $data);
	    }
	}
	// 读取群组聊天缓存
	public function getGroupChatMessageCache($gid, $id){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getGroupChatMessageCache($gid, $id);
	        return $result;
	    }
	}
	// 添加记录id到列表中去
	public function addGroupChatIdToList($gid, $id){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addGroupChatIdToList($gid, $id);
	    }
	}
	
	// 返回聊天列表
	public function getGroupChatList($gid, $id, $start, $length){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getGroupChatList($gid, $id, $start, $length);
	        return $result;
	    }
	}
	
	// 删除列表
	public function delGroupChatIdList($gid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delGroupChatIdList($gid);
	    }
	}
	
	// 获取列表创建时间
	public function getChatListCacheCtime($gid){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getChatListCacheCtime($gid);
	        if (!empty($result)){
	            return $result['ctime'];
	        }
	        return 0;
	    }
	}
	// 设置列表创建时间
	public function setChatListCacheCtime($gid){
	    if (AC::REDIS_WRITE){
	        $data = array('ctime' => AC::SERVER_TIME);
	        $this->redisModel->setChatListCacheCtime($gid, $data);
	    }
	}
	#  chatgroup  end      #
	
	// 聊天室
	public function getChatRoomListByCategory ($category, $start, $end) {
	    if (AC::REDIS_READ){
	        return $this->redisModel->getChatRoomListByCategory($category, $start, $end);
	    }
	}
	
	public function addChatRoomToCategoryList ($rid, $category, $dateline) {
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addChatRoomToCategoryList($rid, $category, $dateline);
	    }
	}
	
	public function delChatRoomFromCategoryList ($rid, $category) {
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->delChatRoomFromCategoryList($rid, $category);
	    }
	}
	
	public function setChatRoomData ($rid, $data) {
	    if (AC::REDIS_WRITE) {
	        return $this->redisModel->setChatRoomData($rid, $data);
	    }
	}
	
	public function getChatRoomData ($rid) {
	   if (AC::REDIS_READ) {
	        return $this->redisModel->getChatRoomData($rid);
	   }
	}
	
	public function delChatRoomData ($rid) {
	   if (AC::REDIS_WRITE) {
	        return $this->redisModel->delChatRoomData($rid);
	   }
	}
	
	public function updateChatRoomMembers ($rid, $field, $num = 1) {
	    if (AC::REDIS_WRITE) {
	        return $this->redisModel->updateChatRoomMembers($rid, $field, $num);
	    }
	}
	
	public function addUserToChatRoom ($rid, $uid, $time) {
	    if (AC::REDIS_WRITE) {
	        return $this->redisModel->addUserToChatRoom($rid, $uid, $time);
	    }
	}
	
	public function getUsersFromChatRoom ($rid) {
	    if (AC::REDIS_READ) {
	        return $this->redisModel->getUsersFromChatRoom($rid);
	    }
	}
	
	public function getChatRoomUserCount ($rid) {
	    if (AC::REDIS_READ) {
	        return $this->redisModel->getChatRoomUserCount($rid);
	    }
	}
	
	public function getUserScoreFromChatRoom ($rid, $uid) {
	    if (AC::REDIS_READ) {
	        return $this->redisModel->getUserScoreFromChatRoom($rid, $uid);
	    }
	}
	
	public function setUserActive ($rid, $uid, $time) {
	    if (AC::REDIS_WRITE) {
	        return $this->redisModel->setUserActive($rid, $uid, $time);
	    }
	}
	
	public function delUserFromChatRoom ($rid, $uid) {
	    if (AC::REDIS_WRITE) {
	        return $this->redisModel->delUserFromChatRoom($rid, $uid);
	    }
	}
	
	public function delChatRoomSet ($rid) {
	    if (AC::REDIS_WRITE) {
	        return $this->redisModel->delChatRoomSet($rid);
	    }
	}
	
	#  推荐人相关 #
	public function getUserScore($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getUserScore($uid);
	    }
	}
	
	public function addRecommentUser($type, $values, $uid){
	    if (AC::REDIS_WRITE){
	       return  $this->redisModel->addRecommentUser($type, $values, $uid);
	    }
	}
	
	public function recommentUserList($type, $start=0, $end= -1){
	    if (AC::REDIS_READ){
	       return  $this->redisModel->recommentUserList($type,$start,$end);
	    }
	}
	
	public function setBoardUids($type, $uid){
	    if (AC::REDIS_WRITE){
	        return  $this->redisModel->setBoardUids($type, $uid);
	    }
	}
	
	public function getBoardUids($type = 'active', $start=0, $end= -1){
	    if (AC::REDIS_READ){
	        return  $this->redisModel->getBoardUids($type, $start, $end);
	    }
	}
	#   end   #  
	
	#   检查用户的关系,与日记的关系,与用户的关系        #
	public function checkIsMeLike($uid, $bodyId){
	    if (AC::REDIS_READ){
	       return $this->redisModel->checkIsMeLike($uid, $bodyId);
	    }
	}
	
	public function checkIsFans($uid, $fUid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->checkIsFans($uid, $fUid);
	    }
	}
	
	public function checkIsBlocked($uid, $fUid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->checkIsBlocked($uid, $fUid);
	    }
	}

	public function checkIsFriend($uid, $fUid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->checkIsFriend($uid, $fUid);
	    }
	}
	#    end     #
	
	/**
	 * 获取好友备注
	 * @param unknown $fUid
	 * @param unknown $uid
	 * @param uid为被查找用户  fUid为本人
	 */
	public function getRmask($fUid,$uid){
	    if (AC::REDIS_READ){
	        return   $this->redisModel->getRmaskCache($fUid,$uid);
	    }
	}
	
	/**
	 * 添加好友备注
	 * @param unknown $uid
	 * @param unknown $fUid
	 * @param uid为本人  fUid为备注用户 data备注用信息
	 * @param unknown $data
	 */
	public function addRmask($uid, $fUid, $data){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addRmaskCache($uid, $fUid, $data);
	    }
	}
	
	/**
	 * 删除好友备注
	 * @param unknown $uid
	 * @param $fUid 被设置备注名者
	 * @param unknown $data
	 */
	public function removeRmask($uid, $fUid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->removeRmaskCache($uid, $fUid);
	    }
	}
	
	/**
	 * 设置用户推送设置缓存
	 * @param unknown $uid
	 * @param unknown $data
	 */
	public function setUserPushInfoCache ($uid, $data) {
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->setUserPushInfoCache($uid, $data);
	    }
	}
	
	/**
	 * 获取用户推送设置缓存
	 * @param unknown $uid
	 */
	public function getUserPushInfoCache ($uid) {
	    if (AC::REDIS_READ){
	        return   $this->redisModel->getUserPushInfoCache($uid);
	    }
	}
	
	/**
	 * 删除用户推送设置的缓存
	 * @param unknown $uid
	 */
	public function delUserPushInfoCache ($uid) {
	    if (AC::REDIS_WRITE){
	        return   $this->redisModel->delUserPushInfoCache($uid);
	    }
	}
	
	/**
	 * 获取我喜欢的日记列表
	 * @param unknown $uid
	 * @param unknown $start
	 * @param unknown $length
	 */
	public function getMeLikesList($uid, $start = 0, $length = 20){
	    if (AC::REDIS_READ){
	        $length = $length ? $length : AC::LIKE_LIST_DISPLAY_LEN;
	        if (intval($start) > 0){
	            $length = $start + $length;
	            $start++;
	        }
	        return $this->redisModel->getMelikeList($uid, $start, $length);
	    }
	}
	
	/**
	 * 增加我喜欢的日记列表
	 * @param unknown $uid
	 * @param unknown $bodyId
	 */
	public function addMeLikesList($uid, $bodyId, $time=AC::SERVER_TIME){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addMeLikesList($uid, $bodyId);
	    }
	}
	/**
	 * 删除某个喜欢的日记
	 * @param unknown $uid
	 * @param unknown $bodyId
	 */
	public function delMeLikesList($uid, $bodyId){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delMeLikesList($uid, $bodyId);
	    }
	}
	/**
	 * 判断日记是否喜欢
	 * @param unknown $uid
	 * @param unknown $bodyId
	 */
	public function checkIsLike($uid, $bodyId){
	    if (AC::REDIS_READ){
	        return $this->redisModel->checkIsLike($uid, $bodyId);
	    }
	}
	
	/**
	 * 统计喜欢数目
	 * @param unknown $uid
	 */
	public function countMeLikes($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->countMeLikes($uid);
	    }
	}
	
	
	/**
	 * 获取上次评论的时间
	 * @param unknown $uid
	 */
	public function getCommentCheck($uid){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getCommentCheck($uid);
	        return $result;
	    }
	}
	
	/**
	 * 设置当前评论的时间
	 * @param unknown $uid
	 * @param unknown $info
	 */
	public function setCommentCheck($uid,$info){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setCommentCheck($uid, $info);
	    }
	}
	
	/**
	 * 增加用户token
	 * @param unknown $uid
	 * @param unknown $info
	 */
	public function addUserToken($uid,$info){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addToken($uid, $info);
	    }
	}
	
	/**
	 * 删除用户token
	 * @param unknown $uid
	 */
	public function delUserToken($uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delToken($uid);
	    }
	}
	
	/**
	 * 获取用户token
	 * @param unknown $uid
	 * @return Ambigous <boolean, unknown>
	 */
	public function getUserToken($uid){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getToken($uid);
	        return $result;
	    }
	}
	
	/**
	 * 获取热门全部
	 * @param unknown $start
	 * @param unknown $end
	 * @return unknown
	 */
	public function getHotDiaryListAll($start, $end){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getHotDiaryAll($start, $end);
	        return $result;
	    }
	}
	
	public function getHotDiaryScore ($bodyId) {
	    if (AC::REDIS_READ){
	        return $this->redisModel->getHotDiaryScore($bodyId);
	    }
	}

	public function getTopDiaryScore ($gid, $bodyId) {
		if (AC::REDIS_READ){
			return $this->redisModel->getTopDiaryScore($gid, $bodyId);
		}
	}
	
	public function getHotDiaries($id, $length){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getHotDiaries($id, $length);
	        return $result;
	    }
	}

    public function setTopicHotDiary($topicId, $bodyId, $time = AC::SERVER_TIME) {
        if (AC::REDIS_WRITE) {
            return $this->redisModel->setTopicHotDiary($topicId, $bodyId, $time);
        }
    }
    public function getTopicHotDiary($topicId, $start, $length) {
        if (AC::REDIS_READ) {
            $length = $start + $length - 1;
            return $this->redisModel->getTopicHotDiary($topicId, $start, $length);
        }
    }
    public function getTopicHotDiaryAll($topicId) {
        if (AC::REDIS_READ) {
            return $this->redisModel->getTopicHotDiaryAll($topicId);
        }
    }

    public function getTopicHotDiaryRank($topicId, $bodyId) {
        if (AC::REDIS_READ) {
            return $this->redisModel->getTopicHotDiaryRank($topicId, $bodyId);
        }
    }

    public function getTopicHotDiaryCount($topicId) {
        if (AC::REDIS_READ) {
            return $this->redisModel->getTopicHotDiaryCount($topicId);
        }
    }

    public function delTopicHotDiaryKey($topicId) {
        if (AC::REDIS_WRITE) {
            return $this->redisModel->delTopicHotDiaryKey($topicId);
        }
    }

    public function delTopicHotDiaryCache($topicId, $bodyId) {
        if (AC::REDIS_WRITE) {
            return $this->redisModel->delTopicHotDiaryCache($topicId, $bodyId);
        }
    }

    public function getTopicHotDiaryKeys($start, $length) {
        if (AC::REDIS_READ) {
            return $this->redisModel->getTopicHotDiaryKeys($start, $length);
        }
    }

	
	/**
	 * 获取热门分类
	 * @param unknown $category
	 * @param unknown $start
	 * @param unknown $end
	 * @return unknown
	 */
	public function getHotDiaryListByCategory($category, $start, $end){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getHotDiaryList($category, $start, $end);
	        return $result;
	    }
	}
	
	/**
	 * 热门推荐日记
	 * @param unknown $id
	 * @param unknown $unionKeys
	 * @param unknown $length
	 * @return multitype:
	 */
	public function getHotRecommendDiary($id, $unionKeys, $length){
	    if (AC::REDIS_READ){
	        $list = $this->redisModel->getHotRecommendDiary($id, $unionKeys, $length);
	        return $list;
	    }
	}
	
	/**
	 * 获取管理员列表
	 * @return unknown
	 */
	public function getAdminUserList(){
	    if (AC::REDIS_READ){
	        $userList = $this->redisModel->getAdminList();
	        return  $userList;
	    }
	}
	
	/**
	 * 统计好友数
	 * @param unknown $uid
	 */
	public function countFriends($uid){
	    if (AC::REDIS_READ){
	       return   $this->redisModel->countFriends($uid);
	    }   
	}
	// 清空粉丝
	public function removeFans($uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->deleteFans($uid);
	    }
	}
	
	/**
	 * 统计粉丝数
	 * @param unknown $uid
	 */
	public function countFans($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->countFans($uid);
	    }
	}
	
	/**
	 * 增加用户计数
	 * @param unknown $data
	 */
	public function addUserCount($uid, $data){
	    if (AC::REDIS_WRITE){
	        if(!empty($data)){
	            foreach ( $data as $key => $val ){
	                $this->redisModel->addUserCount($uid, $key, $val);
	            }
	        }
	    }
	}
	
	
	
	/**
	 * 增加队列
	 * @param unknown $do
	 * @param unknown $keyId
	 */
	public function addSkeysKestrel($do, $uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addSkeysKestrel($do, $uid);
	    }
	}
	
	/**
	 * 查找队列是否已经存在某用户
	 * @param unknown $do
	 * @param unknown $uid
	 * @return unknown
	 */
	public function findSkeysKestrel($do, $uid){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->findSkeysKestrel($do, $uid);
	        return $result;
	    }
	}
	
	/**
	 * 初始化用户统计
	 * @param unknown $uid
	 * @param unknown $info
	 */
	public function initUserCount($uid, $info){
	    if (AC::REDIS_WRITE){
	        // 删除不需要缓存的字段
	        unset($info['uid']);
	        unset($info['id']);
	        unset($info['status']);
            $this->redisModel->initUserCount($uid, $info);
	    }
	}
	
	/**
	 * 获取用户统计
	 * @param unknown $uid
	 * @return Ambigous <boolean, unknown>
	 */
	public function getUserCount($uid,$type=null){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getUserCount($uid,$type);
	        return $result;
	    }
	}
	
	/**
	 * 删除用户缓存
	 * @param unknown $uid
	 */
	public function delUserCache($uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delUserCache($uid);
	    }
	}
	
	/**
	 * 增加用户缓存
	 * @param unknown $data
	 */
	public function addUserCache($data){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addUserCache($data['uid'], $data);
	    }
	}
	
	/**
	 * 获取用户缓存
	 * @param unknown $uid
	 * @return Ambigous <boolean, unknown>|NULL
	 */
	public function getUserCache($uid){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getUserCache($uid);
	        if (!empty($result)) {
			    $result['signature'] = UK::getstr($result['signature'],100,'',1);
	        	$result['nickname']  = UK::getstr($result['nickname'],24,'',1);
	        	$result['nickname']  = UK::replaceNickname($result['nickname'], $uid);
	        }
	        return $result;
	    }
	    return array();
	}
	
	/**
	 * 获取粉丝列表
	 * @param unknown $uid
	 */
	public function getFansList($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->fansList($uid);
	    }
	}
	
	/**
	 * 获取黑名单列表
	 * @param unknown $uid
	 * @return unknown
	 */
	public function getBlackList($uid){
	    if (AC::REDIS_READ){
            $result    =   $this->redisModel->blockedList($uid);
            return $result;
        }
	}
	
	/**
	 * 统计我拉黑的数量
	 * @param unknown $uid
	 */
	public function countBlacks($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->countBlockeds($uid);
	    }
	}
	
	/**
	 * 删除黑名单
	 * @param unknown $uid
	 * @param unknown $fUid
	 */
	public function delBlackList($uid, $fUid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delBlocked($uid, $fUid);
	    }
	}
	
	/**
	 * 加入黑名单
	 * @param unknown $uid
	 * @param unknown $fUid
	 */
	public function addBlackList($uid, $fUid, $time=AC::SERVER_TIME){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addBlocked($uid, $fUid, $time);
	    }
	}
	
	/**
	 * 清空黑名单
	 * @param unknown $uid
	 * @param unknown $fUid
	 */
	public function removeBlacked($uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->deleteBlocked($uid);
	    }
	}
	
	/**
	 * 删除好友
	 * @param unknown $uid
	 * @param unknown $fUid
	 */
	public function delFriends($uid, $fUid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delFriends($uid, $fUid);
	    }
	}
	
	public function removeFriends($uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->deleteFriends($uid);
	    }
	}
	
	/**
	 * 获取好友列表
	 * @param $uid
	 */
	public function getFriendsList($uid){
	    if (AC::REDIS_READ){
	        $uids = $this->redisModel->friendsList($uid);
	        return $uids;
	    }
	}
	/**
	 * 增加好友
	 * @param unknown $uid
	 * @param unknown $fUid
	 */
	public function addFriends($uid, $fUid, $time=AC::SERVER_TIME){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addFriends($uid, $fUid, $time);
	    }
	}
	/**
	 * 增加粉丝
	 * @param unknown $uid
	 * @param unknown $fUid
	 */
	public function addFans($uid, $fUid, $time=AC::SERVER_TIME){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addFans($uid, $fUid, $time);
	    }
	}
	
	/**
	 * 重构时间线,批量增加,倒叙排列
	 * @param unknown $uid
	 * @param unknown $bodyId
	 */
	public function addManyFeedTimeline($uid,$bodyId){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addManyTimeLine($uid, $bodyId);
	    }
	}
	
	/**
	 * 删除动态时间线
	 * @param unknown $uid
	 */
	public function delFeedTimeline($uid){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delTimeLine($uid);
	    }
	}
	
	/**
	 * 获取关注时间线
	 * @param unknown $uid
	 * @param unknown $bodyId
	 * @param string $start
	 * @param string $length
	 * @return unknown
	 */
	public function getUserTimeline($uid, $bodyId, $start= 0, $length= 20){
	    if (AC::REDIS_READ){
	        $length--;
	        $timeLineList = $this->redisModel->getTimeLine($uid, $bodyId, $start, $length);
	        return $timeLineList;
	    }
	}
	
	/**
	 * 加入关注时间线
	 * @param unknown $uid
	 * @param unknown $bodyId
	 */
	public function addUserTimeline($uid, $bodyId){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addTimeLine($uid,$bodyId);
	    }
	}
	
	/**
	 * 获取动态时间线
	 * @param unknown $uid
	 * @param unknown $feedId
	 * @param string $start
	 * @param string $length
	 * @return unknown
	 */
	public function getUserFeedTimeline($uid, $feedId, $start=0, $length=20){
	    if (AC::REDIS_READ){
	        $timeLineList = $this->redisModel->getUserFeedTimeline($uid, $feedId, $start, $length, FALSE);
	        return $timeLineList;
	    }
	}
	
	public function addPushToList ($json_str) {
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addPushToList($json_str);
	    }
	}
	
	/**
	 * 获取动态时间线
	 * @param unknown $uid
	 * @param unknown $feedId
	 * @param string $start
	 * @param string $length
	 * @return unknown
	 */
	public function getUserFeedMeTimeline($uid, $feedId, $start=0, $length=20){
	    if (AC::REDIS_READ){
	        $length--;
	        $timeLineList = $this->redisModel->getUserFeedTimeline($uid, $feedId, $start, $length, TRUE);
	        return $timeLineList;
	    }
	}
	
	/**
	 * 获取动态缓存
	 * @param unknown $feedId
	 * @return Ambigous <multitype:, boolean, unknown>
	 */
	public function getFeedInfoCache($feedId){
	    if (AC::REDIS_READ){
	        $result =   $this->redisModel->getFeedInfoCache($feedId);
	        if (!empty($result)){
	            return $result;
	        }
	        return false;
	    }
	}
	
	/**
	 * 设置公告列表缓存
	 * @param unknown $feedId
	 * @param unknown $time
	 */
	public function setAnnounceCache($feedId,$time=AC::SERVER_TIME){
	    if (AC::REDIS_READ){
	        $result =   $this->redisModel->setAnnounceCache($feedId,$time);
	    }
	}
	
	/**
	 * 获取公告feedid列表
	 * @param number $start
	 * @param unknown $length
	 * @return unknown
	 */
	public function getAnnounceCache($id=0,$length=20){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getAnnounceCache($id,$length);
	    }		
	}
	
	/**
	 * 返回用户未读的公告列表
	 * @param unknown $lastTime
	 */
	public function getNewAnnounceList($lastTime=AC::SERVER_TIME){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getNewAnnounceList($lastTime);
	    }
	}
	
	/**
	 * 添加动态缓存
	 * @param unknown $feedId
	 * @param unknown $feedInfo
	 * @return Ambigous <multitype:, boolean, unknown>
	 */
	public function setFeedInfoCache($feedId, $feedInfo){
	    if (AC::REDIS_READ){
	        $result =   $this->redisModel->setFeedInfoCache($feedId, $feedInfo);
	    }
	}
	
	/**
	 * 加入广场最新时间线
	 * @param unknown $bodyId
	 * @param string $label
	 */
	public function addSquareTimeline($bodyId, $label='0'){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addSquareTimeline('0', $bodyId);
	        if(intval($label) > 0 && intval($label) <  AC::DIARY_TAG_MAXID){
	            $this->redisModel->addSquareTimeline($label, $bodyId);
	        }
	    }
	}
	
	/**
	 * 增加提及我时间线,尚未启用
	 * @param unknown $uid
	 * @param unknown $bodyId
	 */
	public function addMentionTimeline($uid, $bodyId){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addMentionsTimeLine($uid, $bodyId);
	    }
	}
	
	
	/**
	 * 判断是否重复发日志
	 * @param unknown $uid
	 */
	public function getLastCheckConnent($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getDiaryCheck($uid);
	    }
	}
	
	public function setLastCheckConnent($uid, $connent){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setDiaryCheck($uid, $connent);
	    }
	}
	
	/**
	 * 判断是否重复评论日志
	 * @param unknown $uid
	 */
	public function getLastCheckCommentConnent($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getDiaryCommentCheck($uid);
	    }
	}
	
	public function setLastCheckCommentConnent($uid, $connent){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->setDiaryCommentCheck($uid, $connent);
	    }
	}
	
	/**
	 * 判断是否重复发话题
	 * @param unknown $uid
	 */
	public function getLastCheckConnentOfTopic($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getTopicCheck($uid);
	    }
	}
	
	public function setLastCheckConnentOfTopic($uid, $connent){
	    $this->redisModel->setTopicCheck($uid, $connent);
	}
	/**
	 * 初始化日记计数
	 * @param unknown $bodyId
	 * @param unknown $diary
	 */
	public function initDiaryNums($bodyId, $diary){
	    if (AC::REDIS_READ){
    	    $counts = array(
    	            'viewTimes'    =>   $diary['viewTimes'],
    	            'commentTimes' =>   $diary['commentTimes'],
    	            'likeTimes'    =>   $diary['likeTimes'],
    	            'shareTimes'   =>   $diary['shareTimes'],
    	            'repostTimes'  =>   $diary['repostTimes'],
    	    );
    	    if (intval($counts['viewTimes']) < 1){
    	        $counts['viewTimes'] = 1;
    	    }
    	    $this->redisModel->initDiaryCount($bodyId, $counts);
	    }
	    return true;
	}
	
	/**
	 * 增加日记计数
	 * @param unknown $diaryInfo
	 */
	public function addDiaryNums($diaryInfo){
	    if (AC::REDIS_WRITE){
            isset($diaryInfo['viewTimes'])      &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'viewTimes');
            isset($diaryInfo['commentTimes'])   &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'commentTimes');
            isset($diaryInfo['likeTimes'])      &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'likeTimes');
            isset($diaryInfo['shareTimes'])     &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'shareTimes');
            isset($diaryInfo['repostTimes'])    &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'repostTimes');
        }
        return true;
	}
	
	/**
	 * 减少日记计数
	 * @param unknown $diaryInfo
	 */
	public function decDiaryNums($diaryInfo){
	    if (AC::REDIS_WRITE){
	        isset($diaryInfo['viewTimes'])      &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'viewTimes', -1);
	        isset($diaryInfo['commentTimes'])   &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'commentTimes', -1);
	        isset($diaryInfo['likeTimes'])      &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'likeTimes', -1);
	        isset($diaryInfo['shareTimes'])     &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'shareTimes', -1);
	        isset($diaryInfo['repostTimes'])    &&  $this->redisModel->addDiaryCount($diaryInfo['bodyId'], 'repostTimes', -1);
	    }
	    return true;
	}
	
	/**
	 * 获取日记计数
	 * @param unknown $bodyId
	 * @return multitype:NULL Ambigous <boolean, unknown>
	 */
	public function getDiaryNums($bodyId){
	    if (AC::REDIS_READ){
	        $nums   = array();
	        $nums    = $this->redisModel->getDiaryCount($bodyId);
	        
	        return $nums;
	    }
	}
	
	/**
	 * 获取日记缓存
	 * @param unknown $bodyId
	 * @return Ambigous <multitype:, boolean, unknown>
	 */
	public function getDiaryCache($bodyId){
	    if (AC::REDIS_READ){
	        $result =   $this->redisModel->getDiaryCache($bodyId);
	        if (!empty($result)){
	             $result['attachmentList'] = json_decode($result['attachmentList'], true);
	             $result['voiceList']      = json_decode($result['voiceList'], true);
                 if ($videoList = json_decode($result['videoList'], true)){
					 $result['videoList']      = $videoList;
				 }else{
					 $result['videoList']       = [];
				 }
				if ($linkList = json_decode($result['linkList'], true)){
					$result['linkList']      = $linkList;
				}else{
					$result['linkList']       = [];
				}
				return $this->rebuildDiaryCacheInfo($result);
	        }
	        return false;
	    }
	}
	
	/**
	 * 删除日记缓存
	 * @param unknown $bodyId
	 */
	public function delDiaryCache($bodyId){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delDiaryCache($bodyId);
	    }
	}
	/**
	 * 删除广场最新
	 * @param unknown $info
	 */
	public function delDiarySquare($info){
	    if (AC::REDIS_WRITE){
    	    $this->redisModel->delSquareTimeline('0', $info['bodyId']);
    	    if (intval($info['label']) > 0){
    	        $this->redisModel->delSquareTimeline($info['label'], $info['bodyId']);
    	    }
	    }
	}
	/**
	 * 删除日记时删除改篇日记的相关信息
	 * @param unknown $bodyId
	 * @param unknown $uid
	 * @param string $label
	 */
	public function removeDiaryAll($bodyId, $uid, $label='0'){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->delDiaryCache($bodyId);
	        $this->redisModel->lremTimeLine($uid,$bodyId);
	        $this->redisModel->delSquareTimeline('0', $bodyId);
	        if (intval($label) > 0){
	            $this->redisModel->delSquareTimeline($label, $bodyId);
	        }
	        
	    }
	}
	
	private function rebuildDiaryCacheInfo(&$data){
	    $diaryNums = $this->getDiaryNums($data['bodyId']);
	    
	    $data['repostTimes']    =    intval($diaryNums['repostTimes'])  > 0   ? $diaryNums['repostTimes']  : '0';
	    $data['viewTimes']      =    intval($diaryNums['viewTimes'])    > 0   ? $diaryNums['viewTimes']    : '1';
	    $data['commentTimes']   =    intval($diaryNums['commentTimes']) > 0   ? $diaryNums['commentTimes'] : '0';
	    $data['likeTimes']      =    intval($diaryNums['likeTimes'])    > 0   ? $diaryNums['likeTimes']    : '0';
	    $data['shareTimes']     =    intval($diaryNums['shareTimes'])   > 0   ? $diaryNums['shareTimes']   : '0';
	    
	    return $data;
	}
	
	/**
	 * 增加日记缓存
	 * @param unknown $bodyId
	 * @param unknown $result
	 */
	public function addDiaryCache($bodyId, $data){
	    if (AC::REDIS_WRITE){
	        $result = $this->checkDiaryInfo($data);
	        isset($result['attachmentList']) && $result['attachmentList'] = json_encode($result['attachmentList']);
	        isset($result['voiceList'])      && $result['voiceList']      = json_encode($result['voiceList']);
	        isset($result['videoList'])      && $result['videoList']      = json_encode($result['videoList']);
			isset($result['linkList'])      && $result['linkList']      = json_encode($result['linkList']);
	        $this->redisModel->addDiaryCache($bodyId, $result);
	    }
	    return true;
	}
	
	public function checkDiaryInfo($data){
        $diaryInfo = array();
        $diaryInfo['id']             =    strval($data['id']);
        $diaryInfo['uid']            =    strval($data['uid']);
        $diaryInfo['nickname']       =    empty($data['nickname']) ? '' : $data['nickname'];
        $diaryInfo['rBodyId']        =    empty($data['rBodyId']) ? '' : strval($data['rBodyId']);
        $diaryInfo['rUid']           =    empty($data['rUid']) ? '' : strval($data['rUid']);
        $diaryInfo['bodyId']         =    strval($data['bodyId']);
        $diaryInfo['title']          =    empty($data['title']) ? '' : $data['title'];
        $diaryInfo['abbreviation']   =    $data['abbreviation'];
        $diaryInfo['secret']         =    strval($data['secret']);
        $diaryInfo['attachmentPath'] =    empty($data['attachmentPath']) ? '' : $data['attachmentPath'] ;
        $diaryInfo['attachmentList'] =    $data['attachmentList'];
        $diaryInfo['voiceList']      =    $data['voiceList'];
        $diaryInfo['videoList']      =    $data['videoList'];
		$diaryInfo['linkList']       =    $data['linkList'];
        $diaryInfo['time']           =    strval($data['time']);
        $diaryInfo['status']         =    strval($data['status']);
        $diaryInfo['label']          =    empty($data['label']) ? '0' : $data['label'];
        $diaryInfo['type']           =    '1';
        $diaryInfo['commentPeople']  =    strval($data['commentPeople']);
        $diaryInfo['last_time']      =    AC::SERVER_TIME;
        $diaryInfo['topics']         =    $data['topics'];
        $diaryInfo['extras']         =    $data['extras'];
        $diaryInfo['geo']            =   empty($data['geo']) ? '' : $data['geo'];
        $diaryInfo['inReview']       =   isset($data['inReview']) ? $data['inReview'] : 0;
        $diaryInfo['vote']           =   isset($data['vote']) ? $data['vote'] : '0';
        return $diaryInfo;
	}
	// 更新日记最后读取时间
	public function updateDiaryTime($bodyId){
	    if (AC::REDIS_WRITE){
	        $data['last_time'] = AC::SERVER_TIME;
	        $this->redisModel->updateDiaryTime($bodyId, $data);
	    }
	}
	// 更新用户最后读取时间
	public function updateUserTime($uid){
	    if (AC::REDIS_WRITE){
    	    $data['update_time'] = AC::SERVER_TIME;
    	    $this->redisModel->updateUserCache($uid, $data); 
	    }
	}
	// 更新token的最后读取时间
	public function updateTokenTime($uid){
	    if (AC::REDIS_WRITE){
    	    $data['last_time'] = AC::SERVER_TIME;
    	    $this->redisModel->updateTokenTime($uid, $data);
	    }
	}
	// 更新用户达人状态
	public function updateUserAbility($uid, $status){
	    if (AC::REDIS_WRITE){
	        $data['is_ability'] = $status;
	        $this->redisModel->updateUserCache($uid, $data);
	    }
	}
	// 更新用户达人等级
	public function updateUserAbilityLevel($uid, $ability_level){
	    if (AC::REDIS_WRITE){
	        $data['ability_level'] = $ability_level;
	        $this->redisModel->updateUserCache($uid, $data);
	    }
	}
    // 获取用户订阅号列表
    public function getSubscriptionCache($start, $len){
        if (AC::REDIS_READ){
            $len = $start + $len - 1;
            return $this->redisModel->getSubscriptionCache($start, $len);
        }
    }
    //搜索订阅号排序列表
    public function findSubscription($uid) {
        if (AC::REDIS_READ){
            return $this->redisModel->findSubscription($uid);
        }
    }
    //添加、更新订阅号
    public function setSubscriptionUids($uid,$sort){
        if (AC::REDIS_WRITE){
            return  $this->redisModel->setSubscriptionUids($uid, $sort);
        }
    }
    //删除订阅号
    public function delSubscription(){
        if (AC::REDIS_WRITE){
            return  $this->redisModel->delSubscription();
        }
    }
    //返回达人用户在集合中的下标
    public function getSubscriptionRank($uid){
        if (AC::REDIS_WRITE){
            return  $this->redisModel->getSubscriptionRank($uid);
        }
    }
	// 获取用户动态刷新时间(feedupdatetime)
	public function getUserFeedCache($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getUserFeedCache($uid);
	    }
	}
	// 更新用户动态刷新时间(feedupdatetime)
	public function updateUserFeedTime($uid){
	    if (AC::REDIS_WRITE){
	        $data['feed_upt'] = AC::SERVER_TIME;
	        $this->redisModel->updateUserFeedCache($uid, $data);
	    }
	}
	// 获取用户通知刷新时间(feedmeupdatetime)
	public function getUserFeedMeCache($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getUserFeedMeCache($uid);
	    }
	}
	// 更新用户通知刷新时间(feedmeupdatetime)
	public function updateUserFeedMeTime($uid){
	    if (AC::REDIS_WRITE){
	        $data['fdme_upt'] = AC::SERVER_TIME;
	        $this->redisModel->updateUserFeedMeCache($uid, $data);
	    }
	}
	
	/**
	 * 获取用户刷新时间
	 * @param unknown $uid
	 * @return Ambigous <boolean, unknown>
	 */
	public function getUserFlushTimeCache($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getUserFlushTimeCache($uid);
	    }
	}
	
	/**
	 * 设置用户刷新时间(feeds、notice)
	 * @param unknown $uid
	 * nt_t    用户通知刷新时间
	 * fs_t    用户动态刷新时间
	 * rs_t    用户重建关注粉丝列表的时间
	 * ld_t    用户重建喜欢的日记列表的时间
	 * ar_t    读取公告时间
	 */
	public function updateUserFlushTimeCache($uid, $data){
	    if (AC::REDIS_WRITE){
	        $cache_data = array();
	        isset($data['nt_t']) && $cache_data['nt_t'] = AC::SERVER_TIME;
	        isset($data['fs_t']) && $cache_data['fs_t'] = AC::SERVER_TIME;
	        isset($data['rs_t']) && $cache_data['rs_t'] = AC::SERVER_TIME;
	        isset($data['ld_t']) && $cache_data['ld_t'] = AC::SERVER_TIME;
	        //isset($data['ar_t']) && $cache_data['ar_t'] = AC::SERVER_TIME;
		if (!empty($cache_data)) {
		    $this->redisModel->updateUserFlushTimeCache($uid, $cache_data);
		}
	        return TRUE;
	    }
	}
	
	/**
	 * 获取用户禁言缓存
	 * @param unknown $uid
	 */
	public function getGagUserCahce($uid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getShutUpUserCache($uid);
	    }
	}
	
	/**
	 * 设置用户状态信息
	 * @param $uid
	 * @return boolean
	 */
	public function setUserStatus($uid, $data)
	{
	    if (AC::REDIS_READ){
	        return $this->redisModel->setUserStatus($uid, $data);
	    }
	}
	 
	/**
	 * 获取用户状态信息
	 * @param $uid
	 * @return boolean || array
	 */
	public function getUserStatus($uid)
	{
	    if (AC::REDIS_READ){
	        return $this->redisModel->getUserStatus($uid);
	    }
	}
	
	/**
	 * 信纸缓存
	 * @param unknown $pid
	 * @param unknown $data
	 */
	public function setDiaryPaperCache($pid,$data){
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->setDiaryPaperCache($pid, $data);
	    }
	}
	
	/**
	 * 购买量计数增加
	 * @param unknown $pid
	 */
	public function addSoldCountCache($pid,$type){
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addSoldCountCache($pid,$type);
	    }
	}
	
	/**
	 * 获取信纸缓存
	 * @param unknown $pid
	 */
	public function getPaperDetailByIdCache($pid){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getPaperDetailByIdCache($pid);
	    }
	}
	
	/**
	 * 删除信纸缓存
	 * @param unknown $pid
	 */
	public function delPaperCacheById($pid){
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->delPaperCacheById($pid);
	    }
	}
	public function getStatisticalErrorCount($field){
	    if (AC::REDIS_READ){
	        return $this->redisModel->getStatisticalErrorCount($field);
	    }
	}
	
	public function addStatisticalErrorCount($field, $num){
	    if (AC::REDIS_WRITE){
	        $this->redisModel->addStatisticalErrorCount($field, $num);
	    }
	}

	public function getPlannerCategoryCacheList($type){
		if (AC::REDIS_READ){
			return $this->redisModel->getPlannerCategoryCacheList($type);
		}
	}

	public function addPlannerCategoryCache($type,$cid){
		if (AC::REDIS_WRITE){
			$this->redisModel->addPlannerCategoryCache($type,$cid);
		}
	}

    /**
     * 删除精选id
     * @param $bodyid
     */
    public function delRecommendTopic($tid){
        if (AC::REDIS_WRITE){
            return $this->redisModel->delRecommendTopic($tid);
        }
    }

    public function removeRecommendTopic(){
        if (AC::REDIS_WRITE){
            return $this->redisModel->removeRecommendTopic();
        }
    }

    public function getRecommendTopicList($start, $len){
        if (AC::REDIS_READ){
            $len = $start + $len;
            $ids = $this->redisModel->getRecommendTopicList($start, $len);
            return $ids;
        }
    }

    public function addRecommendTopic($tid, $time=AC::SERVER_TIME){
        if (AC::REDIS_WRITE){
            return $this->redisModel->addRecommendTopic($tid, $time);
        }
    }

	public function setHotTypeTopics($type, $value){
		$value = json_encode($value);
		return $this->redisModel->setHotTypeTopics($type, $value);
	}

    public function getHotTypeTopics($type){
        $ret = $this->redisModel->getHotTypeTopics($type);
        if ($ret = json_decode($ret, true)) return $ret;
        return [];
    }

    public function delHotTypeTopics($type){
        return $this->redisModel->delHotTypeTopics($type);
    }
	
    //获取粉粉id登录白名单
    public function getLoginFFIDAllowList(){
        if (AC::REDIS_READ){
            $ids = $this->redisModel->getLoginFFIDAllowList();
            return $ids ? $ids : [];
        }
    }
    
    /**
     * 删除推荐点滴bodyid
     * @param $bodyid
     */
    public function delRecommendDianDiForU($bodyid){
        if (AC::REDIS_WRITE){
            return $this->redisModel->delRecommendDianDiForU($bodyid);
        }
    }

    public function removeRecommendDianDiForU(){
        if (AC::REDIS_WRITE){
            return $this->redisModel->removeRecommendDianDiForU();
        }
    }

    public function getRecommendDianDiForUList($start, $len){
        if (AC::REDIS_READ){
            $len = $start + $len;
            $ids = $this->redisModel->getRecommendDianDiForUList($start, $len);
            return $ids;
        }
    }

    public function addRecommendDianDiForU($bodyid, $time=AC::SERVER_TIME){
        if (AC::REDIS_WRITE){
            return $this->redisModel->addRecommendDianDiForU($bodyid, $time);
        }
    }

    public function getPlannerCacheByType($key){
        if (AC::REDIS_READ){
            $result = $this->redisModel->getPlannerCacheByType($key);
            return $result;
        }
    }

    public function setPlannerCacheByType($key,$data){
        if (AC::REDIS_WRITE){
            $result = $this->redisModel->setPlannerCacheByType($key,$data);
            return $result;
        }
    }

    public function delPlannerCacheByType($key){
        if (AC::REDIS_WRITE){
            $result = $this->redisModel->delPlannerCacheByType($key);
            return $result;
        }
    }

    public function isUidRemoving($uid){
        if (AC::REDIS_WRITE){
            $result = $this->redisModel->isUidRemoving($uid);
            return $result;
        }
    }

    /**
     * 获取匿名最新列表
     * @param $Info
     * @return array
     */
    public function getAnonymousNewList($info)/*{{{*/
    {
        $category = intval($info ['category']);
        $category = ($category > 0 && $category < 19) ? $category : 0;
        $lenth = AC::DIARY_LIST_DEFAULT_LEN;
        if (! empty( $info["length"] )) {
            $lenth = intval ( $info["length"] );
            if ($lenth < 1 || $lenth > AC::DIARY_LIST_DEFAULT_LEN ) {
                $lenth = AC::DIARY_LIST_DEFAULT_LEN;
            }
        }
        $bodyId    =    '0';
        if (intval($info['id']) > 0){
            $bodyId    = intval($info['id']);
        }
        $result = $this->redisModel->getAnonymousTimeline($category, $bodyId, '0', $lenth);
        $bodyList =array();
        if (!empty($result)){
            foreach($result as $bodyId){
                $list['bodyId'] = $bodyId;
                $bodyList[]  =  $list;
            }
        }
        return $bodyList;
    }

    /**
	 * 增加点滴热门评论缓存
	 * @param unknown $data
	 */
	public function addHotComment($bodyId, $weight, $commentId){
	    if (AC::REDIS_WRITE){
	        return $this->redisModel->addHotComment($bodyId, $weight, $commentId);
	    }
	}

	public function delHotComment($bodyId, $commentId){
	    if (AC::REDIS_WRITE) {
	        return $this->redisModel->delHotComment($bodyId, $commentId);
        }
    }
	
	/**
	 * 获取点滴热门评论缓存
	 * @param unknown $bodyId
	 * @return Ambigous <boolean, unknown>|NULL
	 */
	public function getHotComment($bodyId, $start = 0, $length = 20){
	    if (AC::REDIS_READ){
	        $result = $this->redisModel->getHotComment($bodyId, $start, $length);
	        return $result;
	    }
	    return array();
	}

    /**
     * 添加至最新匿名
     * @param $bodyId
     * @param string $label
     */
    public function addAnonymousTimeline($bodyId, $category='0'){
        if (AC::REDIS_WRITE){
            $this->redisModel->addAonoymoousTimeline($category, $bodyId);
        }
    }

    public function delAnonymousTimeline($bodyId, $category='0'){
        if (AC::REDIS_WRITE){
            $this->redisModel->delAnonymousTimeline($category, $bodyId);
        }
    }

    public function getAnonyCheckConnent($uid, $bodyid){
        if (AC::REDIS_WRITE){
            return $this->redisModel->getAnonyCheckConnent($uid, $bodyid);
        }
    }

    public function setAnonyCheckConnent($uid, $bodyid, $content){
        if (AC::REDIS_WRITE){
            $this->redisModel->setAnonyCheckConnent($uid, $bodyid, $content);
        }
    }

    public function getStringByKey($key){
        if (AC::REDIS_READ){
            return $this->redisModel->getStringByKey($key);
        }
    }

    public function removeStringByKey($key){
        if (AC::REDIS_READ){
            return $this->redisModel->removeStringByKey($key);
        }
    }

    public function addStringByKey($key, $data, $ttl=259200){
        if (AC::REDIS_READ){
            return $this->redisModel->addStringByKey($key, $data, $ttl);
        }
    }

    public function delRecommendAnonymousList($bodyid){
        if (AC::REDIS_WRITE){
            return $this->redisModel->delRecommendAnonymousList($bodyid);
        }
    }

    public function removeRecommendAnonymousList(){
        if (AC::REDIS_WRITE){
            return $this->redisModel->removeRecommendAnonymousList();
        }
    }

    public function getRecommendAnonymousList($start=0, $len=-1){
        if (AC::REDIS_READ){
            $ids = $this->redisModel->getRecommendAnonymousList($start, $len);
            return $ids;
        }
    }

    public function addRecommendAnonymousList($bodyid, $time=AC::SERVER_TIME){
        if (AC::REDIS_WRITE){
            return $this->redisModel->addRecommendAnonymousList($bodyid, $time);
        }
    }

    public function delOfficialAnonymousList($bodyid){
        if (AC::REDIS_WRITE){
            return $this->redisModel->delOfficialAnonymousList($bodyid);
        }
    }

    public function getOfficialAnonymousList($start=0, $len=-1){
        if (AC::REDIS_READ){
            $ids = $this->redisModel->getOfficialAnonymousList($start, $len);
            return $ids;
        }
    }

    public function addOfficialAnonymousList($bodyid, $time=AC::SERVER_TIME){
        if (AC::REDIS_WRITE){
            return $this->redisModel->addOfficialAnonymousList($bodyid, $time);
        }
    }
    
    public function getShopDisguise(){
        if (AC::REDIS_READ){
            return $this->redisModel->getShopDisguise();
        }
    }

    public function setShopDisguise($data){
        if (AC::REDIS_WRITE){
            return $this->redisModel->setShopDisguise($data);
        }
    }

    public function getHashCache($hash_key){
        if (AC::REDIS_READ){
            return $this->redisModel->getHashCache($hash_key);
        }
    }

    public function setHashCache($hash_key, $sset_key, $expire, $data, $key){
        if (AC::REDIS_WRITE){
            return $this->redisModel->setHashCache($hash_key, $sset_key, $expire, $data, $key);
        }
    }

    public function detHashCache($hash_key, $sset_key){
        if (AC::REDIS_WRITE){
            return $this->redisModel->detHashCache($hash_key, $sset_key);
        }
    }



    /**
     * 增加屏蔽用户id
     * @param $uid
     * @param $shieldUid
     * @param int $score
     * @return mixed
     */
    public function setUserShieldList($uid, $shieldUid, $score=AC::SERVER_TIME){
        if (AC::REDIS_WRITE) {
            $result = $this->redisModel->setUserShieldList($uid, $shieldUid, $score);
            return $result;
        }
    }

    /**
     * 返回有效屏蔽用户的数量
     * @param $uid
     * @param $min
     * @param $max
     * @return mixed
     */
    public function getUserShieldCount($uid, $min, $max){
        if (AC::REDIS_WRITE) {
            $result = $this->redisModel->getUserShieldCount($uid, $min, $max);
            return $result;
        }
    }

    /**
     * 返回被屏蔽用户的开始时间
     * @param $uid
     * @param $shieldUid
     * @return mixed
     */
    public function findUserShieldList($uid, $shieldUid){
        if (AC::REDIS_READ) {
            return $this->redisModel->findUserShieldList($uid, $shieldUid);
        }
    }

    /**
     * 返回屏蔽列表
     * @param $uid
     * @param bool $withScores
     * @return mixed
     */
    public function getUserShieldList($uid, $withScores=false) {
        if (AC::REDIS_READ) {
            return $this->redisModel->getUserShieldList($uid, $withScores);
        }
    }

    /**
     * 删除屏蔽列表中某一用户id
     * @param $uid
     * @param $shieldUid
     * @return mixed
     */
    public function removeUserShieldListItem($uid, $shieldUid) {
        if (AC::REDIS_WRITE) {
            return $this->redisModel->removeUserShieldListItem($uid, $shieldUid);
        }
    }

    /**
     * 删除列表中时间超过24小时的用户id
     * @param $uid
     * @param $min
     * @param $max
     * @return mixed
     */
    public function removeUserShieldListItemByScore($uid, $min, $max) {
        if (AC::REDIS_WRITE) {
            return $this->redisModel->removeUserShieldListItemByScore($uid, $min, $max);
        }
    }
}
  